package com.hardson.toolkit.swing.datepicker;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.text.JTextComponent;

import com.hardson.toolkit.swing.SwingUtil;
import com.hardson.toolkit.util.DateUtil;

public class DateFieldHandler extends MouseAdapter {
	private int pickType = DatePickerDialog.PICKERTYPE_DATEONLY;
	private String dateFmt = DateUtil.FMT_yyyy_MM_dd;

	public DateFieldHandler() {
	}

	public DateFieldHandler(int pickType, String dateFmt) {
		this.pickType = pickType;
		this.dateFmt = dateFmt;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		JTextComponent comp = (JTextComponent) e.getSource();
		DatePickerDialog.pickDate(SwingUtil.getParentWindow(comp), comp, this.pickType, this.dateFmt);
	}
}
